package com.anjiplus.template.gaea.business.util;

import java.io.IOException;

public class FileZIPUtil {
    private static final String OS = System.getProperty("os.name").toLowerCase();

    public static boolean isWindows() {
        return OS.contains("win");
    }

    public static boolean isLinux() {
        return OS.contains("nix") || OS.contains("nux") || OS.contains("aix");
    }

    public static void createDirectory(String path) throws IOException {
        if (isWindows()) {
            // Windows specific implementation
            Runtime.getRuntime().exec("cmd /c mkdir " + path);
        } else if (isLinux()) {
            // Linux specific implementation
            Runtime.getRuntime().exec("mkdir -p " + path);
        }
    }

    public static void copyFile(String source, String destination) throws IOException {
        if (isWindows()) {
            // Windows specific implementation
            Runtime.getRuntime().exec("cmd /c copy " + source + " " + destination);
        } else if (isLinux()) {
            // Linux specific implementation
            Runtime.getRuntime().exec("cp " + source + " " + destination);
        }
    }

    public static void compressFile(String source, String destination) throws IOException {
        if (isWindows()) {
            // Windows specific implementation
            Runtime.getRuntime().exec("cmd /c compact /c " + source + " " + destination);
        } else if (isLinux()) {
            // Linux specific implementation
            Runtime.getRuntime().exec("tar -czf " + destination + " " + source);
        }
    }
}